Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bare script commands #426

Closed
wants to merge 3 commits into from
Closed

Conversation

N0NB
Copy link
Member

@N0NB N0NB commented Feb 20, 2024

This patch set cleans up an ambiguous example in the man page that resulted in my actual cron entry killing the gnome-keyring-daemon on my system! By using the which command in the scripts and man page example, I hope others can avoid my annoying experience.

Due to the pattern matching of the '-f' option to 'pkill' in the man
page example, use the full path which should avoid matching the command
line of other processes.  For references see:

https://lists.debian.org/debian-user/2023/08/msg00406.html
https://lists.debian.org/debian-user/2023/09/msg00211.html
https://lists.debian.org/debian-user/2024/02/msg00800.html

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1053923

In short the '-f rec' option matched the '--directory' option of
'gnome-keyring-daemon' and killed it at the top of each hour when
'pkill -f rec' was run.

Modifying the script and man page to use the full path (whatever that
might be, typically '/usr/bin/rec' in Linux but could be elsewhere)
should go along way to helping someone avoid similar pain.
Similar to the patch to 'soundlog', use the full path to 'play'.
As backticks are generally hard to see, use the synonymous $() construct
to generate the name for the audio file.  $() is preferred for capturing
the output of a command into a shell variable.
@dl1jbe
Copy link
Member

dl1jbe commented Feb 21, 2024

Oops. Good catch.
Just two questions:

  • Why also use full path to start the programs?
  • Did you experiment with dropping the -f parameter to pkill (as that seems the main culprit) or substitute it by -x (exact match)?

@N0NB
Copy link
Member Author

N0NB commented Feb 21, 2024 via email

@dl1jbe
Copy link
Member

dl1jbe commented Feb 21, 2024

To make the pattern as unique as possible. Besides, it is good practice to do so.

Hmm, I know these practice with complete path to NOT allow bash to pick up the first matching binary with that name in PATH - especially for security reasons..
As 'which()' according to main page uses the same search order as bash the suggested construct would not help here.

Even if there is a locally compiled package that is early in the user's PATH, which should find it.

Yes and the shell would do also.
I am not sure if we really get something useful out of that added complexity.

But back to the main point - the -f parameter:

I did experiment with dropping -f, but I guess I got focused on the way I submitted the patch. Without -f the pattern is limited to 14 characters as I recall which is quite sufficient for rec. Thanks for pointing out -x as I missed that one. A quick check with pgrep shows that it does not match the substring in 'directory'. I suppose that changing -f to -x in the man page template is all that is required to spare others the same pain.

I did some search in gits history. The section in the man page dates back to Rein's work before 2010. Seems that nobody (me included) did a thorough check of that part. Further in all other cases we use 'pkill()' in the source code we have no -f around.

So I agree that changing -f to -x in the man page is the way to go.

@N0NB
Copy link
Member Author

N0NB commented Feb 21, 2024 via email

@dl1jbe dl1jbe mentioned this pull request Feb 22, 2024
@dl1jbe
Copy link
Member

dl1jbe commented Feb 22, 2024

See PR #427

@dl1jbe
Copy link
Member

dl1jbe commented Feb 23, 2024

Replaced by PR #427, so closing these one. Thanks Nate.

@dl1jbe dl1jbe closed this Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants